package com.example.demo.commen;

import com.example.demo.model.Userinfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2023-02-28
 * Time:10:21
 */
public class SessionUtil {
    public static Userinfo getLoginUser(HttpServletRequest request){
        HttpSession session=request.getSession(false);
        if(session!=null&&session.getAttribute(Constant.SESSION_USERINFO_KEY)!=null){
            return (Userinfo) session.getAttribute(Constant.SESSION_USERINFO_KEY);
        }
        return null;
    }
}
